package com.zhongkai.web.control.book;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
@Component
public class ParamType {
	/*true设置绑定的date能否为空，true允许为空，false不允许为空*/
	@InitBinder
	public void initBinder(WebDataBinder binder){
	binder.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"),true));
	}
	
	
	/*将相关的内容输出到jsp页面中*/
	public void toJsp(HttpServletResponse response, String toJspData)throws IOException {	
		response.setHeader("pragma", "no-cache");
		response.setHeader("cache-control", "no-cache");
		PrintWriter out = response.getWriter();
		out.print(toJspData);		
		out.flush();
		out.close();
	}

}
